package projetofinal.wsdl2js.wsdl;

import java.io.File;
import java.io.IOException;

import javax.wsdl.*;

import org.apache.woden.tool.converter.Convert;

import projetofinal.wsdl2js.exception.ExceptionHandler;
import projetofinal.wsdl2js.util.Args;
import projetofinal.wsdl2js.util.Util;

public class WSDLConverter {
	
	public WSDLConverter () {
		//
	}
	
	public void convertToWSDL20 (String aFileName) {
		Args.checkForContent(aFileName);
		
		String wsdlDoc = aFileName;
		String targetDir = Util.getPathWithoutFilename(new File(aFileName));
		String newTargetNS = null;
		boolean verbose = false;
		boolean overwrite = true;
		
		Convert convert = new Convert();
		
		try {
			convert.convertFile(newTargetNS, wsdlDoc, targetDir, verbose, overwrite);
		} catch (WSDLException we) {
			ExceptionHandler.handle(we);
		} catch (IOException ioe) {
			ExceptionHandler.handle(ioe);
		}
		
	}
}
